package com.xqb.listen.ui.main

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.xqb.listen.R
import com.xqb.listen.manager.Constants
import com.xqb.listen.navigation.NavParams
import com.xqb.listen.ui.theme.White
import com.xqb.listen.ui.theme.White10

/**
 * author:17873
 * date:2024/6/16
 * des:MusicPage
 **/

@Composable
fun MusicPage(onSkipPage : (navParams: NavParams) -> Unit) {

    LazyColumn(
        Modifier
            .fillMaxSize()
    ) {
        item {
            MusicTabItem(R.drawable.ic_local_music , R.string.local_music){
                onSkipPage(NavParams(NavParams.Router.LOCAL_MUSIC))
            }
            MusicTabItem(R.drawable.ic_cloud_music , R.string.cloud_music){
                onSkipPage(NavParams(NavParams.Router.CLOUD_MUSIC))
            }
        }
    }
}

//音乐页Item
@Composable
fun MusicTabItem(iconResource : Int , titleResource : Int , onMusicTabItemClick :(itemName : String) -> Unit){

    Row(
        modifier = Modifier
            .height(60.dp)
            .fillMaxWidth()
            .clickable {
                onMusicTabItemClick(Constants.LOCAL_MUSIC)
            },
        verticalAlignment = Alignment.CenterVertically
    ) {

        Image(
            painterResource(iconResource) ,
            null,
            contentScale = ContentScale.Inside,
            modifier = Modifier
                .padding(start = 20.dp)
                .size(45.dp)
                .background(White10, RoundedCornerShape(10.dp))
        )

        Text(
            stringResource(titleResource),
            color = White,
            modifier = Modifier
                .padding(start = 10.dp)
        )
    }
}

